<template>
  <div class="charts">
    <v-chart :option="getOption()" autoresize></v-chart>
  </div>
</template>

<script setup lang="ts">
const getOption = () => {
  return {
    xAxis: {
      show: false,
      type: "category",
    },
    yAxis: {
      show: false
    },
    series: {
      type: 'bar',
      colorBy: "data",
      data: props.data,
      label: {
        show: false,
        position: "insideTop",
        color: "white",
      },
      //延迟动画时间
      animationDelay: function (idx) {
        // 越往后的数据延迟越大
        return idx * 100;
      },
    },
    grid: {
      left: 0,
      top: 0,
      right: 0,
      bottom: 0,
     
    },
    //提示组件
    tooltip: {
      trigger: "axis",
      axisPointer: {
        type: "cross",
      },
      position: function (point, params, dom, rect, size) {
        // 固定在顶部
        return [point[0], "5%"];
      },
    },
  }
}
let props = defineProps(['data'])
// console.log(props.data)
</script>

<style scoped>
.charts {
  width: 100%;
  height: 100%;
}
</style>